<?php

if (count($list->rows)) {

?><?=$this->renderElement('pagination', array('paging' => $list->pagination));?><?php

?><table class="table" cellpadding="0"><?php
?><thead><?php
    ?><tr><?php
        ?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'date', 'msg' => 'created_column', 'domain' => $po_domain));?><?php
        ?></th><?php
        if (Auth::o()->is('admin')) {
            ?><th class="nw"><?php
                ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'client', 'msg' => 'client', 'domain' => $po_domain));?><?php
            ?></th><?php
        }
		?><th class="nw"><?php
            ?><?=$this->renderElement('sort_field', array('obj' => $list->order, 'field' => 'report', 'msg' => 'report_name', 'domain' => $po_domain));?><?php
        ?></th><?php
		?><th class="nw"></th><?php
    ?></tr><?php
?></thead><?php
?><tbody><?php

    $i = 0;
    foreach ($list->rows as $item) {
        $class = '';
    	if ($i++ % 2 != 0) {
    		$sep = strlen($class) ? ' ' : '';
    		$class .= $sep.'altrow';
    	}
    	$class = strlen($class) ? ' class="'.$class.'"' : '';

    	$adding_td_class = (isset($active_reporting_id) && ($active_reporting_id == $item['Reporting']['id'])) ? " active-row" : "";
        ?><tr <?=$class;?>><?php
    		?><td class="nw<?=$adding_td_class;?>"><?php
                ?><?=Date::Short(Date::SQL2UNIX($item['Reporting']['date']));?><?php
            ?></td><?php
            if (Auth::o()->is('admin')) {
        		?><td class="nw<?=$adding_td_class;?>"><?php
                    ?><?=$html->link($item['Client']['name'], "/clients/".$item['Client']['id']."/");?><?php
                ?></td><?php
            }
    		?><td class="nw<?=$adding_td_class;?>"><?php
                ?><?=(!empty($item['Report'])) ? $item['Report']['name'] : "";?><?php
            ?></td><?php
            ?><td class="nw actions"><?php
                ?><table class="sys_clear" cellpadding="0"><?php
                ?><tr class="sys_clear"><?php
                 	?><?=$ehtml->iconLink("download", __d(null, 'download', true), "/reports/download/{$item['Reporting']['id']}");?><?php
            	?></tr><?php
                ?></table><?php
            ?></td><?php
    	?></tr><?php
    }

?></tbody><?php
?></table><?php

?><?=$this->renderElement('pagination', array('paging' => $list->pagination));?><?php

} else {
    ?><span class="additional_msg"><?php
        ?><?=__d($po_domain, 'List is empty', true);?><?php
    ?></span><?php
}

?>